package com.jsnkj.basic.activity

import android.os.Bundle
import com.jsnkj.basic.R
import com.jsnkj.basic.databinding.ActivityTextBinding
import com.jsnkj.basic.mvvm.BaseKtActivity
import com.jsnkj.basic.mvvm.HttpViewModel
import com.jsnkj.basic.util.SharePreferencesUtil
import java.text.SimpleDateFormat
import java.util.Date

class TextActivity : BaseKtActivity<ActivityTextBinding, HttpViewModel>() {
    override val layoutId: Int?
        get() = R.layout.activity_text

    val simpleDateFormat = SimpleDateFormat("yyyy-MM-dd HH:mm:ss") //设置日期格式
    override fun initView(savedInstanceState: Bundle?) {

        var showContent = ""

        com.jsnkj.basic.util.LogUtils.e("数据：${SharePreferencesUtil.getInstance().getAdPostTypeBean()}  ")

        for ((index, bean) in SharePreferencesUtil.getInstance()
            .getAdPostTypeBean().list.withIndex()) {
            showContent += "\n 第$index 数据： ${stampToDate(bean.displayed_at!!)} \n  $bean   \n"

            com.jsnkj.basic.util.LogUtils.e("第$index 数据：$bean  ")
        }

        mVDB.tvShowContent.text = showContent
    }


    fun stampToDate(time: String): String {
        val date = Date(time.toLong())
        val date_Date = simpleDateFormat.format(date)
        return date_Date
    }


}